// imports
import request from '@/utils/request'
import {getImageURL, getDictLabel, getAttachURL} from '@/utils/util'

/**
 * 扩展全局属性，此处封装为方法，方便做框架级调整
 *
 * @param app 挂载对象
 * @param key 属性
 * @param value 值
 */
const extendsProperty = (app, key, value) => {
  app[key] = value
}
export default defineNuxtPlugin(nuxtApp => {
  const app = nuxtApp.vueApp.config.globalProperties
  nuxtApp.provide('request', request)
  // 去掉警告信息
  nuxtApp.vueApp.config.warnHandler = (msg, instance, trace) => {
    console.warn('此处忽略WARN内容，避免展示大量不必要的WARN信息');
  }
  // 获取图片地址
  app.$getImageURL = getImageURL
  // 获取附件地址
  app.$getAttachURL = getAttachURL
  // 获取字典数据
  app.$d = getDictLabel
})
